'''
Created on 16/10/2011

@author: nacho
'''
from stateReady import Ready
from timer  import Timer
from stateRunning import Running

class PCB(object):
    '''
    classdocs
    '''


    def __init__(self, program, pid):
        '''
        Constructor
        '''
        
        self.process = program
        self.state = Ready()
        self.pid = pid
        self.pc = 0
        self.timer= Timer(5.00) 
        
        
    def program(self):
        
        return self.process.fullCode()
    
    def instrNumber(self):
        
        return self.pc
    
    def processID(self):
        
        return self.pid
    
    def increasePC(self):
        
        self.pc += 1
        
    def priority(self):
        
        return self.process.priority()
        
    def toMature(self):
        
        while self.state == Ready():
            self.timer.start()
            self.process.toMature()
    
    def changeStateToRunning(self):
        
        self.state= Running()        
        
    def changeStateToReady(self):
        
        self.state=Ready()
        
    def state(self):
        
        return self.state  
    
    